Skip to content

Cleanup main model: Clean all includes and make some components to be forward declared#1142

Draft
nitbharambe wants to merge 42 commits intomainfrom
feature/component-fwd-cleanup
Draft

Cleanup main model: Clean all includes and make some components to be forward declared#1142
nitbharambe wants to merge 42 commits intomainfrom
feature/component-fwd-cleanup

Conversation

@nitbharambe
Copy link
Member

@nitbharambe nitbharambe commented Sep 29, 2025

Idea is to make components forward declared to reduce coupling.

This draft PR is created for gathering thoughts and requirements as of now.

Changes proposed in this PR include:

  • Forward declared all components
  • Removed unecessary exception and logging includes.

We shall maintain include discipline from now. Include order would be:

For include / source files

  • Important files (Main subjects). (Intention is to highlight for readability and not be strict)
  • Other required files
  • External dependencies
  • Standard library

For tests:

  • Helper includes of test
  • Important files to be tested (Main subjects). (Intention is to highlight for readability and not be strict)
  • Other required files
  • External dependencies
  • Testing dependencies
  • Standard library

In general, use <> for external. "" for internal. Note: PGM includes in test are treated as external, hence they go as <>.

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe self-assigned this Sep 29, 2025
@nitbharambe nitbharambe added the improvement Improvement on internal implementation label Sep 29, 2025
@figueroa1395
Copy link
Member

I like the cleanup. Now I wonder, should we move all_components.hpp to the component folder? Also seems intuitive to me to rename component.hpp to all_components_fwd.hpp, or somehow homogenize the two.

In addition, can we also include component_list in this "revolution"? Perhaps it now belongs in component.hpp and we try to keep all component related stuff in one location only.

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@sonarqubecloud
Copy link

nitbharambe and others added 6 commits December 11, 2025 12:47
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe marked this pull request as ready for review January 7, 2026 13:32
Copy link
Member

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional thing is that perhaps #1142 (comment) is still relevant. Also, maybe triggering Copilot for review might be useful since missing things for a human due to the nature of this PR is very easy.

Rest looks good, just minor questions.

nitbharambe and others added 2 commits January 12, 2026 09:26
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe marked this pull request as draft January 26, 2026 14:32
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
nitbharambe and others added 7 commits February 2, 2026 17:14
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe changed the title Cleanup main model: Make components to be forward declared Cleanup main model: Clean all includes and make some components to be forward declared Feb 3, 2026
Copy link
Member

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of this! I just left a couple remarks.

#include "meta_data.hpp"

#include "../common/common.hpp"
#include "../common/counting_iterator.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out by the CI, add this via Jinja instead of directly editing here.

Comment on lines 10 to -13

#include "../common/common.hpp"
#include "../common/enum.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem.


#include <doctest/doctest.h>

// NOLINTBEGIN(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see many of these, probably related to nlohmann/json. Shouldn't we instead exclude it via misc-include-cleaner.IgnoreHeaders as we did with Eigen?

]
}
})json"s;
})json"s; // NOLINT(misc-include-cleaner) https://github.com/llvm/llvm-project/issues/98122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are annoying but I guess there is nothing else to do about them...

auto const& attribute_name = MetaData::attribute_name(attribute_meta);
// TODO need a way for common angle: u angle skipped for now
if (attribute_name == "u_angle"s) {
if (attribute_name == "u_angle"s) { // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed adding github issue name there. Same as others. Its with operator s

auto const& node = meta_map.get_component("node");
auto const& node_attr = node.attributes;
CHECK(node_attr[0].name == "id"s);
CHECK(node_attr[0].name == "id"s); // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these a problem here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator s

#include <power_grid_model/common/exception.hpp>
#include <power_grid_model/common/grouped_index_vector.hpp>
#include <power_grid_model/common/three_phase_tensor.hpp>
#include <power_grid_model/math_solver/short_circuit_solver.hpp> // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it asking to directly import things called in the short circuit module? Or what's the issue?

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome progress

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find clangd giving a lot more insights than microsoft c++. It spotted many of the cleaned up things of header files which is not possible via clang-tidy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will bring up configuration in a knowledge sharing session.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, maybe add the extension to the workspace recommendations?

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement on internal implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants